package world.snowcrystal.snowcrystalinterface.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import world.snowcrystal.snowcrystalinterface.model.User;

@RestController
@RequestMapping("/name")
public class NameController {


    private static final Logger log = LoggerFactory.getLogger(NameController.class);

    @ExceptionHandler(Exception.class)
    public String handleException(Exception e) {
        return "5400: Exception occurred: " + e.getMessage();
    }

    @GetMapping("/")
    public String getName(@RequestParam String name) {
        return String.format("GET : Hello, %s!", name);
    }

    @PostMapping(value = "/")
    public String postName(@RequestBody User user) {
        log.info("POST : Hello, {}!", user.getUserName());
        return String.format("POST : Hello, %s!", user.getUserName());
    }


}
